package cs294s.liveradar.ui;

import cs294s.liveradar.service.BlipManager;

import android.content.ContextWrapper;
import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.Button;
import android.widget.ImageView;
import java.util.ArrayList;

import android.content.Context;
import android.content.Intent;

import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.Toast;

import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;

import cs294s.liveradar.LocationFacts;
import cs294s.liveradar.LocationTabWidget;
import cs294s.liveradar.Preferences;


public class BlipOverlay extends BalloonItemizedOverlay<OverlayItem>{
	private ArrayList<OverlayItem> m_overlays = new ArrayList<OverlayItem>();
	private Context c;

	public BlipOverlay(Drawable defaultMarker, MapView mapView) {
		super(boundCenter(defaultMarker), mapView);
		c = mapView.getContext();
	}

	public void addOverlay(OverlayItem overlay) {
		m_overlays.add(overlay);
		populate();
	}

	@Override
	protected OverlayItem createItem(int i) {
		return m_overlays.get(i);
	}

	@Override
	public int size() {
		return m_overlays.size();
	}

	@Override
	protected boolean onBalloonTap(int index) {
		Toast.makeText(c, "onBalloonTap for overlay index " + index,
				Toast.LENGTH_LONG).show();
		Activity a = new Activity();
		a.startActivity(new Intent(c, LocationTabWidget.class));

		return true;
	}

}
